public class Calculator {
    private int a; //借了多少钱
    private int m; //借了多少月
    private  double y; //年利率

    private double avgInterest;
    private double avgCap;
    public Calculator(int a, int m,double y){
        this.a = a;
        this.m = m;
        this.y = y;
    }

    public void calculateAvgInterest(){
        avgInterest = (m+1) * a * (y/12) / 2;
        print(1);
    }

    public void calculateAvgCap(){
        double x = Math.pow((1+y/12),m);
        avgCap = m * a * (y/12) * x / (x-1) - a;
        print(2);
    }

    public void print(int type){
        if(type == 1){
            System.out.println("AVGINT:" + avgInterest);
        }
        if(type == 2){
            System.out.println("AVGCAP:" + avgCap);
        }
    }
}
